﻿using Microsoft.Extensions.DependencyInjection;

namespace Chat_WebApi.ConfigServices;

public static class CorsService
{
    /// <summary>
    /// 添加core 服务
    /// </summary>
    /// <param name="services"></param>
    public static void AddCorsService(this IServiceCollection services)
    {
        // 配置SignalR服务 配置跨域
        services.AddCors(options => options.AddPolicy(
            "CorsPolicy",
            builder =>
            {
                builder
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .WithOrigins("http://localhost:20893")
                    .WithOrigins("http://localhost:8002")
                    .WithOrigins("http://localhost:8001")
                    .WithOrigins("http://192.168.0.108:8001")
                    .WithOrigins("http://192.168.0.108:8002")
                    .WithOrigins("http://192.168.0.108:8000")
                    .AllowCredentials();
            }));
    }
}